﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using DevExpress.UserSkins;

namespace QLHS
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.BonusSkins).Assembly);
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Blue");
            DevExpress.Skins.SkinManager.EnableFormSkins();
            Application.Run(new frm_Main());
        }
        //........................
        public static SqlConnection con = null;
        public static string str;
        public static void connect()
        {
            //str = "Data Source=" + frmLogin.sv + ";Initial Catalog=QLLuong;Integrated Security=True";
            str = "Data Source=.;Initial Catalog=QLHS;Integrated Security=True";
            con = new SqlConnection(str);
            try
            {
                con.Open();
                //MessageBox.Show("Ket noi thanh cong!...")
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void disconnct()
        {
            con.Close();
            con.Dispose();
        }
        public static DataTable Loaddata(string sql, string[] name, object[] values, int thamso)
        {
            SqlCommand cmd = new SqlCommand(sql, con);
            for (int i = 0; i < thamso; i++)
            {
                cmd.Parameters.AddWithValue(name[i], values[i]);
            }
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        public static DataTable Getdata(string sql)
        {
            SqlCommand cmd = new SqlCommand(sql, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
    }
}
